from pydub import AudioSegment
import sys
import cv2
import numpy as np
import os

def mixSingleAudio(src,back):
    # 加载原始音频和背景乐
    original_audio = AudioSegment.from_file(src)
    background_music = AudioSegment.from_file(back)
    # 确保背景乐长度不会超过原始音频
    if background_music.duration_seconds > original_audio.duration_seconds:
        background_music = background_music[:original_audio.duration_seconds * 1000]
    # 将背景乐与原始音频混合（这里是将背景乐添加到原始音频的开始）
    combined_audio = background_music.overlay(original_audio)
    # 导出最终音频
    combined_audio.export(src.replace(".wav","_final.wav"), format="wav")
if __name__ == '__main__':
   prameters = []
   for i in range(1, len(sys.argv)):
      prameters.append(str(sys.argv[i]))
   mixSingleAudio(prameters[0],prameters[1])